BIN=mytest
SRC=$(shell ls *.c)
OBJ=$(SRC:.c=.o)
CC=gcc
RM=rm -f

$(BIN):$(OBJ)
	$(CC) $^ -o $@
	@echo "链接 $^ 成 $@"
%.o:%.c
	$(CC) -c $<
	@echo "编译... $< 成  $@"

.PHONY:clean
clean:
	$(RM)  $(OBJ) $(BIN)


#第二版
#BIN=mytest
#SmC=test.c
#OBJ=mytest.o
#CC=gcc
#RM=rm -f
#
#$(BIN):$(OBJ)
#	$(CC) $(OBJ) -o $(BIN)
#
#$(OBJ):$(SRC)
#	$(CC) -c $(SRC) -o $(OBJ)
#
#
#.PHONY:clean
#clean:
#	$(RM) $(BIN) $(OBJ)







#第一版
#mytest:mytest.o
#	gcc mytest.o -o mytest
#
#
#mytest.o:test.c
#	gcc test.c -o mytest.o
#
#.PHONY:clean
#clean:
#	rm -f *.o mytest
